package com.pengshun.modules.api.news.service.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.pengshun.modules.api.coal.validator.First;
import com.pengshun.modules.api.coal.validator.Fourth;
import com.pengshun.modules.common.DateUtil;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 快讯表
 * @TableName ps_news_flash
 */
@Data
public class NewsFlashDto implements Serializable {
    /**
     * 快讯id
     */
    @NotNull(message = "快讯id不能为空",groups = Fourth.class)
    private Long newsFlashId;

    List<NewsFlashDto> dtos;
    /**
     * 标题
     */
    @NotNull(message = "标题不能为空", groups = {First.class})
    @Length(max = 50,message = "标题最多50个字", groups = {First.class})
    private String title;
    private String userImage;
    private String cover;

    /**
     * 内容
     */
    @NotNull(message = "内容不能为空", groups = {First.class})
    @Length(max = 500,message = "内容最多500个字", groups = {First.class})
    private String content;
    private Integer categoryId;
    private String showTime;
    /**
     * 1快讯2视频3求助
     */
    @NotNull(message = "类型不能为空", groups = {First.class})
    private String type;

    /**
     * 图片/视频地址
     */
    private String images;

    /**
     * 区域名称
     */
    @NotNull(message = "区域名称不能为空", groups = {First.class})
    private String categoryName;

    /**
     * 标签名称
     */
    @NotNull(message = "标签名称不能为空", groups = {First.class})
    private String lableName;
    private String lableId;

    /**
     * 阅读数量
     */
    private Integer readNum;

    /**
     * 回复数量
     */
    private Integer replyNum;

    /**
     * 点赞数量
     */
    private Integer praiseNum;

    /**
     * 分享微信好友数量
     */
    private Integer wechatFirendNum;

    /**
     * 分享朋友圈数量
     */
    private Integer wechatCircleNum;

    /**
     * 分享微博数量
     */
    private Integer microblogNum;

    /**
     * 发布人id
     */
    private Long userId;

    /**
     * 发布人名称
     */
    private String userName;

    /**
     * 创建时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    private Date createTime;

    /**
     * 发布时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    private Date issueTime;

    /**
     * 审核人
     */
    private String checkName;

    /**
     * 审核时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    private Date checkTime;

    /**
     * 1待发布/2待审核3已发布4未通过4删除
     */
    private String status;

    private static final long serialVersionUID = 1L;

    public String getShowTime() {
        if(checkTime!=null){
            showTime= DateUtil.getAutoTime(checkTime);
        }
        return showTime;
    }
}